//
// Created by Mzoro on 2022/4/16.
//
#include "key.h"
#include <stdio.h>
#include <string.h>

#define WORD_LENGTH 100


int main() {

    char word[WORD_LENGTH];
    struct key *key;
    while (getWord(word, WORD_LENGTH) != EOF) {
        if ((key = searchKey(word)) != NULL) {
            key->count++;
        }
    }

    for (int i = 0; i < KEYS_LENGTH; ++i) {
        key = &keys[i];
        printf("key word %s : %d \n", key->word, key->count);
    }


    return 0;
}

struct key *searchKey(char *word){

    for (int i = 0; i < KEYS_LENGTH; ++i) {
        if (strcmp(word, keys[i].word) == 0) {
            return &keys[i];
        }
    }
    return NULL;
}
